/**
 * 转发工具类
 */
#ifndef __FORWARD_UTIL_H_INCLUDED__
#define __FORWARD_UTIL_H_INCLUDED__

#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>

#include <string>
using std::string;

#ifdef __cplusplus
extern "C" {
#endif

class forward_util{

public:

	static string get_sockaddr_str(sockaddr_in& addr);

	static void print_buff(const char * buff, size_t siz);

	static sockaddr_in get_sockaddr_in(const char* ip, unsigned short port);

	static sockaddr_in get_sockaddr_in(__u32 ip, unsigned short port);

	static string get_addr_by_sockaddr_in(sockaddr_in& si);

	static unsigned short get_port_by_sockaddr_in(sockaddr_in& si);

	static unsigned int get_uid_by_tcp_src_port(unsigned short port);
	static unsigned int get_uid_by_udp_src_port(unsigned short port);

private:
	
	static unsigned int get_uid_by_net_src_port(const char* file_path, unsigned short port);
	static unsigned int get_uid_by_tcp4_src_port(unsigned short port);
	static unsigned int get_uid_by_tcp6_src_port(unsigned short port);
	static unsigned int get_uid_by_udp4_src_port(unsigned short port);
	static unsigned int get_uid_by_udp6_src_port(unsigned short port);

	
	
};

#ifdef __cplusplus
}
#endif

#endif // __FORWARD_UTIL_H_INCLUDED__
